import { _decorator, assetManager, Component, instantiate, Node, Prefab, resources } from 'cc';

import { resLoader } from '../core/resload/resload';
import { bundleManager } from '../core/resload';

const { ccclass, property } = _decorator;

@ccclass('main')
export class main extends Component {
    start() {
        
        
        // watch(b, (newVal) => {
        //     console.log('计算结果变化:', newVal);
        //   });
        this.addExcisePrefab();
    }

    async addExcisePrefab() {
        await this.loadBundle();
        const gameprefab = await resLoader.loadAsync('game', 'prefabs/game', Prefab);
        const excise = instantiate(gameprefab);
        excise.parent = this.node;
        // resources.load('game', (err, prefab: Prefab) => {
        //     if (err) {
        //         console.error(err);
        //     } else {
        //         const excise = instantiate(prefab);
        //         excise.parent = this.node;
        //     }
        // });
        
    }

    async loadBundle() {
        await bundleManager.loadBundles(['monsters', 'game']);
        // excise.parent = this.node;
    }

    update(deltaTime: number) {
        
    }
}

@test
class testClass {
    test() {
        console.log('testClass');
    }
}


function test(target: any) {
    console.log('test', target);
}





